//
//  UIButton+YsToolsManager.m
//  YsToolsManager
//
//  Created by 宋宏康 on 2020/3/20.
//

#import "UIButton+YsToolsManager.h"


@implementation UIButton (YsToolsManager)
+ (instancetype)buttonWithTitle:(NSString *)title
                        backColor:(UIColor *)backColor
                    backImageName:(NSString *)backImageName
                       titleColor:(UIColor *)color
                         fontSize:(int)fontSize
                     cornerRadius:(CGFloat)cornerRadius
{
    
    UIButton *button = [UIButton new];
    [button setTitle:title forState:UIControlStateNormal];
    [button setBackgroundColor:backColor];
    [button setBackgroundImage:[UIImage imageNamed:backImageName] forState:UIControlStateNormal];
    [button setTitleColor:color forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:fontSize];
    [button sizeToFit];
    button.layer.cornerRadius=cornerRadius;
    button.clipsToBounds=YES;
    return button;
}

+ (instancetype)buttonWithTitle:(NSString *)title
                          fontSize:(CGFloat)fontSize
                        titleColor:(UIColor *)titleColor


{
    UIButton *button = [self buttonWithType:UIButtonTypeCustom];
    [button setTitle:title forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:fontSize];
    [button setTitleColor:titleColor forState:UIControlStateNormal];
    return button;
}

+ (instancetype)buttonWithTitle:(NSString *)title
                        backColor:(UIColor *)backColor
                       titleColor:(UIColor *)color
                         fontSize:(int)fontSize
                     cornerRadius:(CGFloat)cornerRadius
{
    UIButton *button = [UIButton new];
    [button setTitle:title forState:UIControlStateNormal];
    [button setBackgroundColor:backColor];
    [button setTitleColor:color forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:fontSize];
    button.layer.cornerRadius=cornerRadius;
    button.clipsToBounds=YES;
    return button;
}

+ (instancetype)buttonWithNormalImage:(UIImage *)normalImage
                          selectImage:(UIImage *)selectImage
                        backColor:(UIColor *)backColor
{
    UIButton *button = [self buttonWithType:UIButtonTypeCustom];
    [button setImage:normalImage forState:UIControlStateNormal];
    [button setImage:selectImage forState:UIControlStateSelected];
    button.backgroundColor = backColor;
    [button sizeToFit];
    return button;
}
@end
